<?=n_mod('nrule')->topNav('设置中心','规则列表')?>
<table id="example" class="a-table a-table-striped">
     <thead>
          <tr>
          <th colspan="3">&nbsp;</th>
          </tr>
     </thead>
     <tbody>
     <?php
     if(!empty($data['list'])){
          $nsite = n_api('nsite');
          foreach($data['list'] as $key=>$val){
               $exist = $nsite->isExistFilterRule($data['scode'],$val['nr_key']);
     ?>
          <tr>
               <th></th>
               <th><?=$val['nr_desc']?></th>
               <td>

               <?php
               if ($val['share'] == 'Y') {//关联
                    echo n_ui(n_url('nsite','nruleMySiteList',array('scode'=>$data['scode'],'rule'=>$val['nr_key'])),'分类') . "&nbsp;";
               }else{
                    echo "<span>&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;&nbsp;</span>";
               }
               //设置
               if ($val['enset'] == 'Y') {
                    echo n_ui(n_url('nconfig','siteIndex',array('scode'=>$data['scode'],'pevent'=>$val['nr_key'])),'设置');
               }else{
                    echo "<span>&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;&nbsp;</span>";
               }
               ?>

               <?php
               if (empty($exist)) {
               ?>
                <a href="javascript:;" style="color:darkkhaki">启用</a>
               <?php
               }else{
               ?>
               <span id="OP-<?=$val['nr_key']?>">
                    <?php
                    if($exist['isdel']=="N"){
                    ?>
                         <a href="javascript:;" onclick="toggle('<?=$data['scode']?>','<?=$val['nr_key']?>');">停用</a>
                    <?php
                    }else{
                    ?>
                         <a href="javascript:;" onclick="toggle('<?=$data['scode']?>','<?=$val['nr_key']?>');">启用</a>
                    <?php
                    }
                    ?>
               </span>

               <?php
               }
               ?>
               </td>
          </tr>
     <?php
          }
     ?>
          <tr>
          <th></th>
          <th>忽略内容</th>
          <td>&nbsp;/&nbsp;&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;&nbsp;
          <a href="<?=n_url('ignore','siteIndex',array('scode'=>$data['scode']))?>">忽略字符</a>
          <a href="<?=n_url('ignore','pairIndex',array('scode'=>$data['scode']))?>">忽略符号</a></td>
          </tr>
     <?php
          }else{
     ?>
     <tr>
          <td colspan="3">
               暂无数据
          </td>
     </tr>
     <?php
     }
     ?>
     </tbody>
     <tfoot>
          <tr><th colspan="3">&nbsp;</th></tr>
     </tfoot>
</table>
<script>
function toggle (scode,pevent) {
     if (confirm("是要改配置？")==false) return true;
     var data = {};
     data['scode'] = scode;
     data['pevent'] = pevent;
     $.post('/nsite/nruleToggle.html',data,function(rs){
          $("#OP-"+pevent).html(rs.msg);
     },'json');
}
</script>